package com.epalmpay.service.trade.impl;

import com.epalmpay.dto.trade.DeviceOnlineRecordInDTO;
import com.epalmpay.entity.Page;
import com.epalmpay.entity.TradeOffline;
import com.epalmpay.mapper.TradeOfflineMapper;
import com.epalmpay.service.trade.IDevOnlineRecordService;
import com.epalmpay.util.DateUtil;
import com.epalmpay.util.Tools;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by wucongpeng on 2017/5/4.
 */

@Service("devOnlineService")
public class DevOnlineRecordServiceImpl implements IDevOnlineRecordService {

    @Resource
    private TradeOfflineMapper tradeOfflineMapper;

    /**列出某门店下的所有交易
     * @param receiverName
     * @return
     * @throws Exception
     */
    @Override
    public List<TradeOffline> listAllRecordByReceiverName(String receiverName) throws Exception {
        return null;
    }


    /**通过订单号获取交易信息
     * @param orderId
     * @return
     * @throws Exception
     */
    @Override
    public TradeOffline getRecordByOrderId(String orderId) throws Exception {
        return null;
    }


    /**通过交易状态查询
     * @param status
     * @return
     * @throws Exception
     */
    @Override
    public TradeOffline findByTransactionStatus(int status) throws Exception {
        return null;
    }


    /**交易记录列表分页
     * @return
     * @throws Exception
     */
    @Override
    public List<TradeOffline> listOnlineRecords(DeviceOnlineRecordInDTO onlineRecordInDTO, Page page)throws Exception{

    	TradeOffline tradeOnline = new TradeOffline();
        tradeOnline.setPage(page);
        tradeOnline.setGroupId(onlineRecordInDTO.getGroupId());
        tradeOnline.setTransactionStatus(onlineRecordInDTO.getTransactionStatus());
        tradeOnline.setGoodType(onlineRecordInDTO.getGoodType());
        tradeOnline.setPayType(onlineRecordInDTO.getPayType());
        tradeOnline.setOrderId(onlineRecordInDTO.getOrderId());
        if (!Tools.isEmpty(onlineRecordInDTO.getJoinStart())) {
            tradeOnline.setJoinStart(DateUtil.fomatDate(onlineRecordInDTO.getJoinStart()));
        }
        if (!Tools.isEmpty(onlineRecordInDTO.getJoinEnd())) {
            tradeOnline.setJoinEnd(DateUtil.getDateNext(onlineRecordInDTO.getJoinEnd(), 1));
        }


        return tradeOfflineMapper.OfflineRecordlistPage(tradeOnline);
    }
}
